package com.ruoyi.project.WebMoudle.ShopSuser.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.WebMoudle.ShopSuser.domain.ShopVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.WebMoudle.ShopSuser.mapper.ShopSuserMapper;
import com.ruoyi.project.WebMoudle.ShopSuser.domain.ShopSuser;
import com.ruoyi.project.WebMoudle.ShopSuser.service.IShopSuserService;
import com.ruoyi.common.utils.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 商铺后台分配Service业务层处理
 * 
 * @author ShopSuser
 * @date 2020-06-22
 */
@Service
public class ShopSuserServiceImpl implements IShopSuserService 
{
    @Autowired
    private ShopSuserMapper shopSuserMapper;

    /**
     * 查询商铺后台分配
     * 
     * @param id 商铺后台分配ID
     * @return 商铺后台分配
     */
    @Override
    public ShopSuser selectShopSuserById(Long id)
    {
        return shopSuserMapper.selectShopSuserById(id);
    }

    /**
     * 查询商铺后台分配列表
     * 
     * @param shopSuser 商铺后台分配
     * @return 商铺后台分配
     */
    @Override
    public List<ShopSuser> selectShopSuserList(ShopSuser shopSuser)
    {
        return shopSuserMapper.selectShopSuserList(shopSuser);
    }

    /**
     * 新增商铺后台分配
     * 
     * @param shopSuser 商铺后台分配
     * @return 结果
     */
    @Override
    @Transactional
    public int insertShopSuser(ShopSuser shopSuser)
    {
        shopSuser.setCreateTime(DateUtils.getNowDate());
        return shopSuserMapper.insertShopSuser(shopSuser);
    }

    /**
     * 修改商铺后台分配
     * 
     * @param shopSuser 商铺后台分配
     * @return 结果
     */
    @Override
    public int updateShopSuser(ShopSuser shopSuser)
    {
        shopSuser.setUpdateTime(DateUtils.getNowDate());
        return shopSuserMapper.updateShopSuser(shopSuser);
    }

    /**
     * 删除商铺后台分配对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteShopSuserByIds(String ids)
    {
        return shopSuserMapper.deleteShopSuserByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商铺后台分配信息
     * 
     * @param id 商铺后台分配ID
     * @return 结果
     */
    @Override
    public int deleteShopSuserById(Long id)
    {
        return shopSuserMapper.deleteShopSuserById(id);
    }
    /*根据系统用户查询店铺*/
    @Override
    public ShopSuser selectOneShopId(Long sysUserId) {
        return shopSuserMapper.selectOneShopId(sysUserId);
    }
    /*根据微信用户查询店铺列表*/
    @Override
    public List<ShopVo> toShopListByWid(Long wxUserId) {
        return shopSuserMapper.toShopListByWid(wxUserId);
    }
    /*根据店铺id查询店铺*/

    @Override
    public List<ShopSuser> queryByShopId(Long shopId) {
        return shopSuserMapper.queryByShopId(shopId);
    }
    /*根据微信用户和商铺id查询唯一的数据*/
    @Override
    public ShopVo queryByWidAndSid(Long wxUserId, Long shopId) {
        return shopSuserMapper.queryByWidAndSid(wxUserId,shopId);
    }

    @Override
    public ShopSuser selectEntityByWidAndSid(Long wxUserId, Long shopId) {
        return shopSuserMapper.selectEntityByWidAndSid(wxUserId,shopId);
    }

    @Override
    public int queryEmpCount(Long shopId) {
        return shopSuserMapper.queryEmpCount(shopId);
    }

    @Override
    public List<String> queryShopWxEmp(Long shopId) {
        return shopSuserMapper.queryShopWxEmp(shopId);
    }
}
